c   MERefPr.for, Reformats Excel ANWR1_VBA prospect output

c    file, ProspData for use in economic analysis

c    program.

c   Writen by Schuenemeyer 3/6/98

c

c   Input file: ProspData (contains successful prospect

c    information from ANWR1 play simulation.

c

c   Output file: Contains recoverable oil/gas and other

c    infomation on prospects (see labels).

c

c   Temporary file created and used: tmp.tmp

c

      character id*80,fn*20,varno*38,varng*38,outf*24

      dimension nn(3),x(8),varno(12),varng(12)

      integer*2 nb(10000)

c   Labels for output file

      data varno/'Simulation Num',

     1 'Num of Prospects',

     2 'Prospect Num',

     3 'Oil=1 or Gas=2',

     4 'Recoverable Oil(mm bbl) or Gas(b cf)',

     5 'Area, 1000 acres',

     6 'Depth from surface, 1000 ft',

     7 'for Oil-Assoc disolved gas, b cf',

     8 'for Oil-NGL from assoc-dis gas, mm bbl',

     9 'for Oil-Formation volume factor',

     a 'for Oil-GOR, cf/bbl at stp',

     b 'NGL ratio, bbl/mm cf'/

      data varng/'',

     1 '',

     2 '',

     3 '',

     4 '',

     5 '',

     6 '',

     7 'for Gas-NGL recover from NA gas,mm bbl',

     8 'for Gas-Orig reservoir pressure, psi',

     9 'for Gas-Temperature, deg Rankine',

     a 'for Gas-Gas compressibility',

     b ''/

	data outf/'(i6,2i4,i2,f11.4,7f10.3)'/

	nvar=12

 	knt=0

      open(8,file='ProspData')

      write(*,*)' Enter full output file name'

      read(*,'(a20)')fn

      open(9,file='tmp.tmp')

      open(10,file=fn)

      call getdat(iyrx,imonx,idayx)

c   read ProspData file

      read(8,'(a80)')id

   10 read(8,*,end=50) nn,x

      knt=knt+1

      write(9,25) nn,x

   25 format(i6,i4,i2,f11.4,7f10.3)

      it=nn(1)

      nb(it)=nn(2)

      goto 10

   50 close (9)

c   create a file with recoverable oil and gas data

      write(10,52)fn, imonx,idayx,iyrx

   52 format('File:',a20,2x,'MMDDYYYY=',2i2.2,i4,3x,

     1 'All Oil and Gas Recoverable')

        write(10,54)nvar,knt,outf

   54 format(i3,i10,3x,a24,2x,'Num of variables, Num of observ',

     1  2x,'Format')

      do i =1, nvar

       write(10,'(a38,2x,a38)')varno(i),varng(i)

      end do

      open(9,file='tmp.tmp')

   60 read(9,25,end=100)nn,x

      it=nn(1)

      write(10,64)it,nb(it),nn(2),nn(3),x

   64 format(i6,2i4,i2,f11.4,7f10.3)

      goto 60

  100 write(*,*)' Num Records',knt

      stop

      END

